import os

from dotenv import load_dotenv
from langchain_community.callbacks import get_openai_callback
from langchain_openai import AzureChatOpenAI

""" begin: 初始化模型...."""
load_dotenv()
model = AzureChatOpenAI(
    # openai_api_key=
    # openai_api_base=os.getenv("AZURE_OPENAI_ENDPOINT"),
    api_key=os.getenv("AZURE_OPENAI_API_KEY"),
    azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
    azure_deployment=os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME"),
    api_version=os.getenv("AZURE_OPENAI_API_VERSION"),
    temperature=0.7
)

""" end: 初始化模型..."""

with get_openai_callback() as cb:
    result = model.invoke("告诉我一个笑话")
    print(result)



